<?php
// 获取评论列表
// header("content-type:text/html;charset=utf-8");
include_once("conn.php");

if (!session_id()) {
    session_start();
}

$uid = $_SESSION['USERINFOS']['uid'];

// 获取评论列表
function getRemark($g_id)
{
    global $conn;
    global $uid;
    $sql_reamrk = "SELECT * FROM tb_remark_info 
                    LEFT JOIN tb_user_info ON tb_remark_info.uid = tb_user_info.uid 
                    WHERE g_id = '$g_id'
                    ORDER BY r_date DESC";
    $result_reamrk = mysqli_query($conn, $sql_reamrk);
    if ($result_reamrk) {
        if (mysqli_num_rows($result_reamrk) > 0) {
            while ($row_reamrk = mysqli_fetch_array($result_reamrk)) {
                if ($row_reamrk['uid'] == $uid) {
                    $del = "<span class='del_remark_sapn'>
                            <a href='php/del-remark.php?g_id=" . $row_reamrk['g_id'] . "&id=" . $row_reamrk[0] . "'>
                                <button type='button' class='btn btn-outline-danger del_remark_btn'>删除</button>
                            </a>
                        </span>";
                } else {
                    $del = "";
                }
                echo "
                <div class='remark_item'>
                    <div class='remark_text'>" . $row_reamrk['content'] . "</div>
                    <div class='remark_info'>
                        <span class='remark_user'>" . $row_reamrk['uname'] . "</span>
                        <span class='remark_time'>" . $row_reamrk['r_date'] . "</span>" . $del . "
                    </div>
                </div>
            ";
            }
        } else {
            echo "<div class='null_remark'><img src='img/null_remark.svg'></div>";
        }
    }
}
